package P049_OverrideToString;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * 覆写toString
 *
 * @author xufy1
 */
public class OverrideToString {

    @Test
    public void test2() {

        System.out.println(new Person("张三"));
    }
}

class Person{

    private String name;

    public Person(String _name) {
        name = _name;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Person) {
            Person p = (Person) obj;
            return name.equalsIgnoreCase(p.getName().trim());
        }
        return false;
    }

    @Override
    public String toString(){
        return String.format("%s.name=%s",this.getClass(),name);
    }
}
